import { Button } from "antd";
import { useMemoizedFn } from "ahooks";
import { useNavigate } from "react-router";
import { ProTable, type ProColumns } from "@ant-design/pro-components";
import PageWrapper from "@/components/PageWrapper";

const ProjectList = () => {
  const navigate = useNavigate();

  const columns: ProColumns[] = [
    {
      title: '项目名称',
      dataIndex: 'name',
    },
    {
      title: '项目类型',
      dataIndex: 'type',
      hideInSearch: true,
    },
    {
      title: '演出时间',
      dataIndex: 'time',
      hideInSearch: true,
    },
    {
      title: '城市',
      dataIndex: 'city',
      hideInSearch: true,
    },
    {
      title: '状态',
      dataIndex: 'status',
      hideInSearch: true
    },
    {
      title: '座位类型',
      dataIndex: 'seatType',
      hideInSearch: true,
    },
    {
      title: '上架状态',
      dataIndex: 'onlineStatus',
      hideInSearch: false,
      valueEnum: {
        0: "上架",
        1: "下架"
      }
    },
    {
      title: '开始时间',
      hideInTable: true,
      dataIndex: 'startTime',
      valueType: 'dateTimeRange',
    },
    {
      title: '优先级',
      dataIndex: 'sort',
      hideInSearch: true,
    },
    {
      key: 'action',
      title: '操作'
    }
  ];

  const handleAdd = useMemoizedFn(() => {
    navigate("/project/list/create");
  });

  return (
    <PageWrapper>
      <ProTable
        columns={columns}
        toolBarRender={() => {
          return [
            <Button
              key="add"
              type="primary"
              onClick={handleAdd}
            >
              新建项目
            </Button>
          ];
        }}
      />
    </PageWrapper>
  );
}

export default ProjectList;